package com.ciaojian.core.enums.business;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.ciaojian.core.enums.base.IBaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Atlakyn
 */
@AllArgsConstructor
@Getter
public enum CounterClickTypeEnum implements IBaseEnum {
    /**
     * 计数类型
     */
    MALL_CLICK(0, "商城点击数", "MALL:"),

    PAY_PAGE_BUY_MEMBER(1, "支付页购买会员成功次数", "PAY_PAGE_BUY_MEMBER:"),

    PAY_PAGE_BUY_MEMBER_CLICK(2, "支付页购买会员点击数", "PAY_PAGE_BUY_MEMBER_CLICK:"),

    BANNER_INTO_DIST(3, "轮播图进入分销", "BANNER_INTO_DIST:"),

    HOME_INTO_DIST(4, "首页支付进入分销", "HOME_INTO_DIST:"),

    TAKE_INTO_DIST(5, "取号成功进分销", "TAKE_INTO_DIST:"),

    STORE_INTO_DIST(6, "门店列表进入分销", "STORE_INTO_DIST:"),

    ;

    @EnumValue
    private Integer value;

    private String description;

    /**
     * 在 Redis 中的存储 key
     */
    private String redisKey;

    /**
     * 根据值找枚举对象
     *
     * @param redisKey Redis key 值
     * @return 枚举对象，如果没找到返回 null
     */
    public static CounterClickTypeEnum getByRedisKey(String redisKey) {
        for (CounterClickTypeEnum e : values()) {
            if (e.getRedisKey().equals(redisKey)) {
                return e;
            }
        }
        return null;
    }
}
